Skip to content

perf: compute volume OBV trend in one pass#21

Open
ShauryaMallampati wants to merge 2 commits into
Dragoon4002:mainfrom
ShauryaMallampati:perf/volume-obv-single-pass
Open

perf: compute volume OBV trend in one pass#21
ShauryaMallampati wants to merge 2 commits into
Dragoon4002:mainfrom
ShauryaMallampati:perf/volume-obv-single-pass

Conversation

@ShauryaMallampati

@ShauryaMallampati ShauryaMallampati commented Jul 5, 2026

Copy link
Copy Markdown

Refs #2.

Summary

  • optimize the volume obv_trend helper to compute prefix OBV and trailing OBV delta in a single pass
  • preserve the existing signal/detail behavior, including the obv_prev zero guard
  • add a regression test comparing the new implementation against the previous two-pass calculation

Benchmark

Local synthetic OHLCV inputs, best of 5 repeats:

  • 5,000 candles / 2,000 calls: old 1.781563s vs new 1.069399s, 1.67x faster
  • 20,000 candles / 500 calls: old 1.794274s vs new 1.072936s, 1.67x faster

Validation

  • .venv/bin/python -m pytest shared/tests/test_volume_algos.py -q
  • .venv/bin/python -m py_compile app/strategies/quant_algos/volume_algos.py shared/tests/test_volume_algos.py
  • git diff --check

Copilot AI review requested due to automatic review settings July 5, 2026 01:01
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

@ShauryaMallampati is attempting to deploy a commit to the dragoon4002's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes the obv_trend volume indicator by collapsing the previous two-pass OBV computation into a single pass, while preserving existing signal and detail-string behavior. Adds regression tests to ensure output parity with the prior implementation, including the "obv_prev zero" guard behavior.

Changes:

  • Refactor obv_trend to compute obv_prev (prefix) and obv_delta (tail) in one loop.
  • Keep existing guard/format behavior (warming up…, "obv_prev zero", and OBV change% formatting).
  • Add tests that compare the new implementation against a two-pass reference and validate the zero-prefix case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/strategies/quant_algos/volume_algos.py Reworks OBV trend computation to a single-pass prefix/tail accumulation for better performance.
shared/tests/test_volume_algos.py Adds regression coverage to ensure the refactor preserves prior results and edge-case behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ShauryaMallampati

Copy link
Copy Markdown
Author

Follow-up on checks: the visible Vercel status is blocked on repo-owner/team authorization, and the GitHub Actions workflows are waiting for maintainer approval to run on this forked PR.

Local validation for this patch:

  • .venv/bin/python -m pytest shared/tests/test_volume_algos.py -q -> 2 passed
  • .venv/bin/python -m py_compile app/strategies/quant_algos/volume_algos.py shared/tests/test_volume_algos.py
  • git diff --check

Copilot reviewed the current diff with no comments.

@ShauryaMallampati

Copy link
Copy Markdown
Author

Follow-up in 225bf3e: moved the volume regression test from shared/tests/ to tests/ so it is included by the repo CI command.

Validation:

  • .venv/bin/python -m pytest tests/test_volume_algos.py -q -> 2 passed
  • .venv/bin/python -m pytest tests/ -q -> 2 passed
  • .venv/bin/python -m py_compile app/strategies/quant_algos/volume_algos.py tests/test_volume_algos.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants